package com.li.controller;

import com.li.pojo.dto.CluesPageDto;
import com.li.pojo.po.*;
import com.li.pojo.vo.AssignmentVo;
import com.li.pojo.vo.falseClueVo;
import com.li.service.ClueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/clues/clue")
@Slf4j
public class ClueController {
    @Autowired
    ClueService clueService;
    //线索分页
    @GetMapping("/list")
    public PageResult list(CluesPageDto cluesPageDto){
        PageResult pageResult=clueService.list(cluesPageDto);
        return pageResult;
    }
    //新增线索
    @PostMapping
    public Result addClue(@RequestBody Clue clue){
        clueService.addClue(clue);
        return new Result(200,"操作成功","");
    }
    //查看线索详情
    @GetMapping("/{id}")
    public Result find(@PathVariable Integer id){
        Clue clue=clueService.find(id);
        return new Result(200,"操作成功",clue);
    }
    //修改线索详情
    @PutMapping
    public Result modifyClu(@RequestBody Clue clue){
        clueService.modifyClu(clue);
        return new Result(200,"操作成功","");
    }
    //伪线索
    @PutMapping("/false/{id}")
    public Result updateClue(@RequestBody falseClueVo falseClueVo,@PathVariable Integer id){
        clueService.updateClue(falseClueVo,id);
        return new Result(200,"操作成功","");
    }
    //线索池
    @GetMapping("/pool")
    public PageResult poolPage(CluesPageDto cluesPageDto){
        PageResult pageResult = clueService.poolPage(cluesPageDto);
        return pageResult;
    }
    //批量捞取
    @PutMapping("/gain")
    public Result reasonGain(@RequestBody AssignmentVo assignmentVo){
        clueService.reasonGain(assignmentVo);
        return new Result(200,"操作成功","");
    }
    //线索转商机
    @PutMapping("/changeBusiness/{id}")
    public Result changeBusiness(@RequestBody Clue clue,@PathVariable Integer id){
        clueService.changeBusiness(clue,id);
        return new Result(200,"操作成功","");
    }
    //批量分配
    @PutMapping("/assignment")
    public Result assignment(@RequestBody AssignmentVo assignmentVo){
        clueService.updateassignment(assignmentVo);
        return new Result(200,"操作成功","");
    }
}
